package com.gyy.GeneralFunction;

import com.gyy.sdk.HCNetSDK;
import com.sun.jna.Pointer;

/**
 * Created by panting6 on 2021/3/4.
 */
public class LightPTZControlWithSpeed {
    static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;

    /**
     * 测温补光灯点亮
     *
     * @param lUserID      用户登录句柄
     * @param iChannelNum  通道号
     * @param dwPTZCommand 云台控制命令，具体命令见设备网络SDK开发手册->NET_DVR_PTZControlWithSpeed_Other
     * @param dwStop       云台停止动作或开始动作：0－开始；1－停止
     * @param dwSpeed      云台控制的速度，用户按不同解码器的速度控制值设置。取值范围[1,7]
     */
    public void lightPTZControlWithSpeed(int lUserID, int iChannelNum, int dwPTZCommand, int dwStop, int dwSpeed) {
        //1.开启补光灯使能3258
        HCNetSDK.NET_DVR_DEVSERVER_CFG InBuffer = new HCNetSDK.NET_DVR_DEVSERVER_CFG();
        InBuffer.read();
        InBuffer.dwSize = InBuffer.size();
        InBuffer.byEnableSupplementLight = 0; // 补光灯控制0-启用，1-禁用
        InBuffer.write();
        Pointer lpInBuffer = InBuffer.getPointer();
        boolean re = hCNetSDK.NET_DVR_SetDVRConfig(lUserID, hCNetSDK.NET_DVR_SET_DEVSERVER_CFG, iChannelNum, lpInBuffer, InBuffer.dwSize);
        if (re) {
            System.out.println("开启补光灯使能成功!!!");

            //2.点亮补光灯NET_DVR_PTZControlWithSpeed（LIGHT_PWRON）
            if (!hCNetSDK.NET_DVR_PTZControlWithSpeed_Other(lUserID, iChannelNum, dwPTZCommand, dwStop, dwSpeed)) {
                System.out.println("PTZ控制参数设置失败，错误号：" + hCNetSDK.NET_DVR_GetLastError());
            } else {
                System.out.println("PTZ控制参数设置成功，dwPTZCommand为:" + dwPTZCommand + "，云台停止动作或开始动作dwStop为:" + dwStop);
            }
        } else {
            System.out.println("开启补光灯使能失败，错误号：" + hCNetSDK.NET_DVR_GetLastError());
        }
    }
}
